# Contributor: knuxify <knuxify@gmail.com>
# Maintainer:
pkgname=py3-pygame
pkgver=2.5.2
pkgrel=2
pkgdesc="Python library for making applications and games based on SDL"
url="https://pygame.org"
arch="all"
license="LGPL-2.1-or-later"
depends="python3 py3-numpy"
depends_dev="
	freetype-dev
	libjpeg-turbo-dev
	libpng-dev
	portmidi-dev<=200
	python3-dev
	sdl2-dev
	sdl2_gfx-dev
	sdl2_image-dev
	sdl2_mixer-dev
	sdl2_ttf-dev
"
makedepends="cython py3-setuptools py3-sphinx $depends_dev"
checkdepends="libvorbis libwebp mpg123 tiff font-dejavu udev"
subpackages="$pkgname-doc $pkgname-dev $pkgname-examples:examples:noarch $pkgname-pyc"
source="https://github.com/pygame/pygame/archive/refs/tags/$pkgver/pygame-$pkgver.tar.gz
	no-werror.patch"
builddir="$srcdir/pygame-$pkgver"

options="!check" # test suite is flaky

# included into same .so, the config scripts only check if /etc/redhat-release
# exists for this lmao
export PORTMIDI_INC_PORTTIME=1

build() {
	python3 setup.py cython build
	python3 setup.py docs
}

check() {
	# Do a temporary install with all of the test files intact
	python3 setup.py install --skip-build --root="$srcdir"/pygame-build

	libpath="$(echo $srcdir/pygame-build/usr/lib/python3.*/site-packages)"

	export SDL_VIDEODRIVER=dummy
	export SDL_AUDIODRIVER=disk
	PYTHONPATH="$libpath" python3 "$builddir"/test \
		-v \
		--exclude=opengl,timing \
		--time_out=300
}

package() {
	python3 setup.py install --skip-build --root="$pkgdir"
	rm -r "$pkgdir"/usr/lib/python3.*/site-packages/pygame/tests
}

doc() {
	default_doc
	amove /usr/lib/python3.*/site-packages/pygame/docs
}

examples() {
	pkgdesc="$pkgdesc (examples)"
	amove /usr/lib/python3.*/site-packages/pygame/examples
}

sha512sums="
b54e9b80951c8a9e75666621aafc26874c6dbdab27330146f7217346c76be5627a5464a0102a5968eca0dbd7cced4b2143cd2ff1b6227e3e17e5634854b27f19  pygame-2.5.2.tar.gz
866c7dae0127f413c979f58d9e80c33449a1230ceac56151546c94d6320c11d1398ea7333e22b23119a604e567cc0e72326d06d1ca0bd3209f02325888940e80  no-werror.patch
"
